package com.bleeth; /**
 * Copyright (c) 2008, 2012 Oracle and/or its affiliates.
 * All rights reserved. Use is subject to license terms.
 */

import com.bleeth.fx.helper.AnimationHelper;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.stage.Stage;
import javafx.util.Duration;

/**
 * A sample showing two arcs with controls to change various settings.
 *
 * @related graphics/shapes/CircleSample
 * @related graphics/shapes/EllipseSample
 * @see javafx.scene.shape.Arc
 * @see javafx.scene.shape.Shape
 * @see javafx.scene.paint.Color
 */
public class ArcSample extends Application {

    private void init(Stage primaryStage) {
        StackPane root = new StackPane();
        primaryStage.setResizable(false);
        primaryStage.setScene(new Scene(root, 400, 400));
// Simple red filled arc
//        Arc arc1 = new Arc(45, 60, 45, 45, 40, 100);
//        arc1.setFill(Color.RED);
// Blue stroked arc
        Arc arc2 = new Arc(200, 200, 90, 90, 90, -360);
        arc2.setStroke(Color.web("#d5d5d5"));
        arc2.setStrokeWidth(45);
        arc2.setFill(null);

// Create a group to show all the arcs);
        Button startButton = new Button("开始");
        root.getChildren().add(new Group(arc2, startButton));


        startButton.setOnAction(event -> {
            arc2.setStroke(Color.web("#a4c1dc"));
            AnimationHelper.Tl()
                    .addKF(arc2.lengthProperty(), 0, Duration.seconds(0))
                    .addKF(arc2.lengthProperty(), -360, Duration.seconds(2))
                    .apply();
        });
    }

    public double getSampleWidth() {
        return 180;
    }

    public double getSampleHeight() {
        return 90;
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        init(primaryStage);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}